# coding:utf-8
class Admin::AdvertisesController < AdminController

  set_tab :business
  respond_to :html, :json

  def index
    @advertises = Advertise
    @advertises = Advertise.order('created_at desc').page params[:page]
    render :layout => "account_group"
  end

  def new
    @advertise = Advertise.new
  end

  def edit
    @advertise = Advertise.find params[:id]
  end

  def create
    @advertise = Advertise.new params[:advertise]
    if @advertise.save
      redirect_to :aciton => :index
    else
      render action: :edit
    end
  end

  def update
    @advertise = Advertise.find params[:id]
    @advertise.update_attributes params[:advertise]    
    redirect_to admin_recruitment_group_path(@advertise.advertise_group_id)
  end

  def destroy
    @advertise = Advertise.find params[:id]
    @advertise.destroy
    redirect_to admin_recruitment_group_path(@advertise.advertise_group_id)
  end

end
